Skip to content

feat(ssh): Add SSH agent auth and configurable sudo#5

Open
f33rx wants to merge 1 commit intodeevus:mainfrom
f33rx:feat/ssh-agent
Open

feat(ssh): Add SSH agent auth and configurable sudo#5
f33rx wants to merge 1 commit intodeevus:mainfrom
f33rx:feat/ssh-agent

Conversation

@f33rx
Copy link
Contributor

@f33rx f33rx commented Feb 16, 2026

Adds three new options to the SSH provider block:

  • use_agent / agent_socket: Authenticate via SSH agent instead of embedding a private key. Falls back to SSH_AUTH_SOCK if no socket is specified.
  • use_sudo: Defaults to true. Set to false when the SSH user can run midclt directly (e.g. a TrueNAS admin account).

private_key becomes optional (still required when use_agent is false). The two are mutually exclusive.

Also refactors the duplicated SSH config construction into a shared buildSSHConfig() helper.

Tests included for all validation paths.

Add use_agent, agent_socket, and use_sudo options to the SSH provider
block. When use_agent is true, authentication uses the SSH agent
(SSH_AUTH_SOCK) instead of a private key. use_sudo defaults to true
but can be disabled when the SSH user can run midclt directly.

Refactors duplicated SSH config construction into buildSSHConfig().
@deevus
Copy link
Owner

deevus commented Feb 23, 2026

Same as #3. This will need to be moved to https://github.com/deevus/truenas-go

Again, my apologies.

deevus added a commit to deevus/truenas-go that referenced this pull request Feb 27, 2026
Add UseAgent, AgentSocket, and NoSudo options to SSHConfig.
When UseAgent is true, authentication uses the SSH agent
(SSH_AUTH_SOCK) instead of a private key. NoSudo skips the
sudo prefix when the SSH user can run midclt directly.

Closes #5

Based on work by Dalton Perdue in deevus/terraform-provider-truenas#5.

Co-Authored-By: Dalton Perdue <dalton@perdue.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@deevus
Copy link
Owner

deevus commented Feb 27, 2026

Please rebase and test against deevus/truenas-go#13 and once confirmed working I will merge upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants